package com.bootssm.service.impl;

import com.bootssm.dao.RecordMapper;
import com.bootssm.pojo.Borrow;
import com.bootssm.pojo.Record;
import com.bootssm.pojo.RecordVO;
import com.bootssm.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordServiceImpl implements RecordService {
    @Autowired
    private RecordMapper recordMapper;

    @Override
    public List<Record> findAll(RecordVO recordVO) {
        Integer start = (recordVO.getPage() - 1) * recordVO.getPageSize();
        recordVO.setPage(start);
        return recordMapper.findAll(recordVO);
    }

    @Override
    public Integer getTotal(RecordVO recordVO) {
        return recordMapper.getTotal(recordVO);
    }

    @Override
    public void delete(String recordId) {
        recordMapper.delete(recordId);
    }

    @Override
    public Record findById(String recordId) {
        return recordMapper.findById(recordId);
    }

    @Override
    public void insert(Borrow borrow) {
        // 1.添加到借阅记录中去
        recordMapper.insert(borrow);
    }
}
